# -*- coding: utf-8 -*-

"""
@Datetime: 2019/1/4
@Author: Zhang Yafei
"""
from flask import Flask, render_template, jsonify, request

app = Flask(__name__)


USERS = {
    '1':{'name':'姚明','count':0},
    '2':{'name':'詹姆斯','count':0},
    '3':{'name':'科比','count':0},
}


@app.route('/user_list')
def user_list():
    return render_template('user_list.html',users=USERS)


@app.route('/vote',methods=['POST'])
def vote():
    uid = request.form.get('uid')
    USERS[uid]['count'] += 1
    return "投票成功"


@app.route('/get/vote',methods=['GET'])
def get_vote():
    return jsonify(USERS)


if __name__ == '__main__':
    app.run()